<!-- TODO -->
<template>
    <div>
        <el-card class="!border-none mt-4" shadow="never">
            <el-table size="large" class="mt-[14px]" :data="pager.lists">
                <el-table-column label="ID" prop="id">
                    <template #default="{ row }">
                        {{ row.id }}
                    </template>
                </el-table-column>
                <el-table-column label="等级名称" prop="name" />
                <el-table-column label="提成比例">
                    <template #default="{ row }"> {{ row.rate }}% </template>
                </el-table-column>
                <el-table-column label="创建时间" prop="created_at" />
				<el-table-column label="修改时间" prop="updated_at" />
                <el-table-column label="操作" fixed="right" min-width="160">
                    <template #default="{ row }">
                        <el-button type="primary" @click="handleEdit(row)"> 编辑 </el-button>
                    </template>
                </el-table-column>
            </el-table>
            <!-- 分页 -->
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
        <edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
    </div>
</template>

<script lang="ts" setup>
import { usePaging } from '@/hooks/usePaging'
import { UserRankList } from '@/api/user'
import EditPopup from './edit.vue'
// import feedback from '@/utils/feedback'

const { pager, getLists } = usePaging({
    fetchFun: UserRankList
})

getLists()

const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const showEdit = ref(false)

const handleEdit = async (data: any) => {
    showEdit.value = true
    await nextTick()
    editRef.value?.open('edit')
    editRef.value?.getDetail(data)
}

</script>
<style lang="scss" scope>
//TODO
.el-alert--warning.is-light {
    background-color: rgba(246, 248, 255, 1);
    color: rgba(64, 115, 250, 1);
}
</style>
